package common
import (
	"github.com/larspensjo/config"
)

const DEFAULT_INI = "./config.ini"

var configInstance *config.Config

func loadConfig() {
	if configInstance == nil {
		c, err := config.ReadDefault(DEFAULT_INI)

		if err != nil {
			Logger(LOG_FATAL, "read the config.ini faild")
		}

		configInstance = c
	}
}

func GetConfigWithString(section string, filed string) string {
	loadConfig()
	c, _ := configInstance.String(section, filed)
	return c
}

func GetConfigWithInt(section string, filed string) int {
	loadConfig()
	c, _ := configInstance.Int(section, filed)
	return c
}
